*****identities

gen libcon73 = v380
recode libcon73 0=. 8/9=. 

gen libcon82 = v1304
recode libcon82 0=. 8/9=.

gen libcon97 = v5300
recode libcon97 96/99=.

gen pid73 = v482
recode pid73 7/9=.
replace pid73 = pid73+1

gen pid82 = v1608
recode pid82 7/9=.
replace pid82 = pid82+1

gen pid97 = v5754
recode pid97 7/9=. 
replace pid97 = pid97+1

*****identity sorting

*73
*folded strength of ideology 1973, coded 1-4
gen ideostr73=4 		if libcon73==1 | libcon73 ==7
replace ideostr73 =3 	if libcon73==2 | libcon73 ==6
replace ideostr73 =2 	if libcon73==3 | libcon73 ==5
replace ideostr73 =1 	if libcon73==4
label variable ideostr73 "Ideological strength, 1 to 4, 4=strong"

*folded strength of ideology 1973, coded 1-4
gen pidstr73=4 			if pid73==1 | pid73 ==7
replace pidstr73 =3 	if pid73==2 | pid73 ==6
replace pidstr73 =2 	if pid73==3 | pid73 ==5
replace pidstr73 =1 	if pid73==4
label variable pidstr73 "partisan strength, 1 to 4, 4=strong"

**combined partisan & ideological strength
gen pidideostr73=pidstr73*ideostr73

**Alignment between partisan and ideological strength
gen overlap73=abs(pid73-libcon73)+1

**make sure you have omscore installed**
omscore overlap73
replace overlap73 =rr_overlap73
label variable overlap73 "overlap between identities, 1973 where hi=most overlap"

**sorting measure
gen overlapxstr73=overlap73*pidideostr73
gen sorting73 = (overlapxstr73-7)/105

*82
*folded strength of ideology 1982, coded 1-4
gen ideostr82=4 		if libcon82==1 | libcon82 ==7
replace ideostr82 =3 	if libcon82==2 | libcon82 ==6
replace ideostr82 =2 	if libcon82==3 | libcon82 ==5
replace ideostr82 =1 	if libcon82==4
label variable ideostr82 "Ideological strength, 1 to 4, 4=strong"

*folded strength of ideology 1982, coded 1-4
gen pidstr82=4 			if pid82==1 | pid82 ==7
replace pidstr82 =3 	if pid82==2 | pid82 ==6
replace pidstr82 =2 	if pid82==3 | pid82 ==5
replace pidstr82 =1 	if pid82==4
label variable pidstr82 "partisan strength, 1 to 4, 4=strong"

**combined partisan & ideological strength
gen pidideostr82=pidstr82*ideostr82

**Alignment between partisan and ideological strength
gen overlap82=abs(pid82-libcon82)+1

**make sure you have omscore installed**
omscore overlap82
replace overlap82 =rr_overlap82
label variable overlap82 "overlap between identities, 1982 where hi=most overlap"

**sorting measure
gen overlapxstr82=overlap82*pidideostr82
gen sorting82 = (overlapxstr82-7)/105

*97
*folded strength of ideology 1997, coded 1-4
gen ideostr97=4 		if libcon97==1 | libcon97 ==7
replace ideostr97 =3 	if libcon97==2 | libcon97 ==6
replace ideostr97 =2 	if libcon97==3 | libcon97 ==5
replace ideostr97 =1 	if libcon97==4
label variable ideostr97 "Ideological strength, 1 to 4, 4=strong"

*folded strength of ideology 1997, coded 1-4
gen pidstr97=4 			if pid97==1 | pid97 ==7
replace pidstr97 =3 	if pid97==2 | pid97 ==6
replace pidstr97 =2 	if pid97==3 | pid97 ==5
replace pidstr97 =1 	if pid97==4
label variable pidstr97 "partisan strength, 1 to 4, 4=strong"

**combined partisan & ideological strength
gen pidideostr97=pidstr97*ideostr97

**Alignment between partisan and ideological strength
gen overlap97=abs(pid97-libcon97)+1

**make sure you have omscore installed**
omscore overlap97
replace overlap97 =rr_overlap97
label variable overlap97 "overlap between identities, 1997 where hi=most overlap"

**sorting measure
gen overlapxstr97=overlap97*pidideostr97
gen sorting97 = (overlapxstr97-7)/105

*****religion
gen bible73 = v750
recode bible73 1=4 2=3 3=2 4=1 5/99=.

gen bible82 = v2323
recode bible82 1=4 2=3 3=2 4=1 5/99=.

gen bible97 = v6502
recode bible97 1=4 2=3 3=2 4=1 5/99=. 0=.

gen attend73= v749
recode attend73 0=. 1=5 2=4 3=3 4=2 5=1 6/99=.

gen attend82 = v2322
recode attend82 0=. 1=5 2=4 3=3 4=2 5=1 6/99=.

gen attend97 = v6501
recode attend97 0=. 1=5 2=4 3=3 4=2 5=1 6/99=.
